package com.example.demo.servlet;

import com.example.demo.dao.UserDao;
import com.example.demo.entity.UserVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/finduser")
public class FindUserServlet  extends HttpServlet {

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("Username");
        int id= Integer.parseInt(req.getParameter("UserID"));
        try {
            new UserDao().findByName(name);
            new UserDao().findUserByName(name);
            new UserDao().findByUserId(id);
            req.getRequestDispatcher("/category/list").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }

    }
}